#include "Common.h"
#include "Engine.h"
#include "Scenes.h"

using namespace Pandora;

#include <iostream>

int main()
{
	CEngine Engine(Refraction());

	Engine.RenderFrame();
	Engine.SaveToFile("atest.tga");

	return 0;
}

/*#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <string>

HWND hWnd;
HDC hdc = NULL;
LRESULT CALLBACK WindowEventProc(HWND hWindow, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
   switch (uMsg)
   {
	case WM_KEYDOWN:
		switch (wParam)
		{
		case VK_ESCAPE:
			PostQuitMessage (0);
			return 0;
		default: break;
		}
	case WM_DESTROY:
		PostQuitMessage (0);
        return 0;
   }
 
   return DefWindowProc(hWindow, uMsg, wParam, lParam);
}

void InitWindow(CScene scene)
{
	HINSTANCE hProg = GetModuleHandle(0);
	WNDCLASS wc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hProg;
	wc.lpfnWndProc = WindowEventProc;
	wc.lpszClassName = "raytracer_asdf";
	wc.lpszMenuName = 0;
	wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
	wc.hIcon = LoadIcon(hProg, IDI_WINLOGO);
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.hCursor = LoadCursor(hProg, IDC_ARROW);

 	RegisterClass(&wc);
	hWnd = CreateWindowEx(0, "raytracer_asdf", "Raytracer - Rendering in progress", WS_OVERLAPPEDWINDOW,
		0, 0, scene.GetWidth(), scene.GetHeight(), 0, 0, hProg, 0);

	ShowWindow(hWnd, SW_NORMAL);
	UpdateWindow (hWnd);
	
	hdc = GetDC(hWnd);
}

int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	CEngine Engine(ThreeSpheresScene());

	InitWindow(Engine.GetScene());

	Engine.RenderFrame();

	SetWindowText(hWnd, "Raytracer - Image Rendered");

	for(int i = 0; i < Engine.GetScene().GetHeight(); i++)
		for(int j = 0; j < Engine.GetScene().GetWidth(); j++)
			SetPixelV(hdc, Engine.GetScene().GetWidth()-j, i, RGB(min(Engine.GetBuffer()[i][j].r*255.0f, 255.0f), min(Engine.GetBuffer()[i][j].g*255.0f,255.0f), min(Engine.GetBuffer()[i][j].b*255.0f, 255.0f)));

    MSG msg;
	msg.message = WM_NULL;
    while(msg.message != WM_QUIT)
    {
        if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

	return static_cast<int>(msg.wParam);
}*/